/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package com.modudf;

import java.awt.Graphics;
import java.awt.Image;
import java.awt.Toolkit;
import java.net.URL;
import javax.swing.JPanel;

public class MyPanel {

    public static JPanel getImage(String name) {
        URL u = MyPanel.class.getResource("resources/" + name);
        final Image image = Toolkit.getDefaultToolkit().getImage(u);
        JPanel panel = new JPanel() {
            @Override
            protected void paintComponent(Graphics g) {
                super.paintComponent(g);
                g.drawImage(image, 0, 0, this);
            }
        };
        return panel;
    }
}
